import 'package:flutter/material.dart';
import 'package:flutter_color_plugin/flutter_color_plugin.dart';

// 键盘类型
const type = [
  TextInputType.number,
  TextInputType.visiblePassword,
  TextInputType.text,
  TextInputType.datetime,
  TextInputType.emailAddress,
  TextInputType.multiline,
  TextInputType.phone,
  TextInputType.url,
];
class CreateMyInput extends StatelessWidget {
  final iconString;
  final placeholder;
  final isPassword;
  final inputController;
  final leadingTitle;
  final int typeNum;
  const CreateMyInput(
      {Key key,
      this.iconString,
      this.placeholder,
      this.isPassword,
      this.inputController,
      this.leadingTitle, this.typeNum})
      : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(12.0, 0, 12.0, 0),
      height: 48,
      margin: EdgeInsets.only(bottom: 10),
      color: Colors.white,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          leadingTitle != ''
              ? Text(leadingTitle,
                  style: TextStyle(
                      color: ColorUtil.color("#FF333333"), fontSize: 15))
              : Image.asset(iconString, width: 25, color: Color(0xff2D4ED1)),
          Expanded(
            flex: 1,
            child: Container(
              decoration: BoxDecoration(
                // border: Border(
                //     bottom: BorderSide(
                //         width: 0.8, color: Color(0xff2D4ED1))), //底部border
              ),
              child: TextField(
                controller: inputController,
                maxLines: 2,
                keyboardType: type[typeNum??0],
                decoration: InputDecoration(
                  hintText: placeholder,
                  contentPadding: EdgeInsets.fromLTRB(
                      0, 14, 0, 14), //输入框内容部分设置padding，跳转跟icon的对其位置
                  border: InputBorder.none,
                ),
                textAlign: TextAlign.end,
                obscureText: isPassword, //是否是以星号*显示密码
                onChanged: (String value){
                },
              ),
            ),
          )
        ],
      ),
    );
  }
}
